package com.softer.wxzj.common.util;

import com.softer.wxzj.mapper.SysOperatorMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;

@Component
@Transactional(rollbackFor = {RuntimeException.class, Exception.class})
@Slf4j
/**   
 * @ClassName: ZoneCodeUtil
 * @Description: 当前用户所在地区code
 * @Author:  zcz
 * @CreateDate: 2019-05-10   
 */
public class OperUtil {

    @Autowired
    private SysOperatorMapper sysOperatorMapper;

    /**
     * 初始化bean文件
     */
    public static OperUtil zoneCodeUtil;

    @PostConstruct
    public void init() {
        zoneCodeUtil = this;
        zoneCodeUtil.sysOperatorMapper = this.sysOperatorMapper;
    }

    /**
     * 获取当前用户地区code
     * @return
     */
    public String getZoneCode() {
        return sysOperatorMapper.getZoneCode(ShiroUserUtil.getUserName());
    }


}
